<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>机构表管理</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <jsp:include page="../com/header.jsp"></jsp:include>
    <script type="text/javascript" src="../../js/comm/listcomm.js"></script>
    <script type="text/javascript">
        var contentUrl = root + "cms/institution/findInstitutionNEStatusPage";
        var editUrl = 'institutionEdit.jsp?id=';
        var operateUrl = root + 'cms/institution/operateInstitutionByIds';
        var getCityListUrl = root + "cms/sysArea/findSysAreaNEStatusPage";
        function getfilter() {
            var _jsonFilter = "{";
            if ($("#search_Institution_Name").val() && $("#search_Institution_Name").val().length > 0) {
                _jsonFilter += "'search_LIKE_institution_Name':'" + $("#search_Institution_Name").val().replace("'", "\"") + "',";
            }
            if ($("#search_Institution_Site").val() && $("#search_Institution_Site").val().length > 0) {
                _jsonFilter += "'search_LIKE_institution_Site':'" + $("#search_Institution_Site").val().replace("'", "\"") + "',";
            }
            if ($("#search_Institution_Informations").val() && $("#search_Institution_Informations").val().length > 0) {
                _jsonFilter += "'search_LIKE_Institution_Informations':'" + $("#search_Institution_Informations").val().replace("'", "\"") + "',";
            }
            if ($("#search_institution_Area").val() && $("#search_institution_Area").val().length > 0) {
                _jsonFilter += "'search_EQ_institution_Area':'" + $("#search_institution_Area").val().replace("'", "\"") + "',";
            }
            if ($("#search_institution_type").val() && $("#search_institution_type").val().length > 0) {
                _jsonFilter += "'search_EQ_institution_type':'" + $("#search_institution_type").val().replace("'", "\"") + "',";
            }
            if ($("#search_institutionAddress").val() && $("#search_institutionAddress").val().length > 0) {
                _jsonFilter += "'search_EQ_institutionAddress':'" + $("#search_institutionAddress").val().replace("'", "\"") + "',";
            }
            if ($("#search_sysAreaId").val() && $("#search_sysAreaId").val().length > 0) {
                _jsonFilter += "'search_EQ_sysAreaId':'" + $("#search_sysAreaId").val().replace("'", "\"") + "',";
            }
            if (_jsonFilter != "{") {
                _jsonFilter = _jsonFilter.substring(0, _jsonFilter.length - 1);
            }
            _jsonFilter += "}";
            return _jsonFilter;
        }

        $(document).ready(function () {
            //加载城市列表
            getCityLists();
            //机构区域改变的时候，改变城市
            $("#search_institution_Area").change(function () {
                var area = $(this).val();//0,1 国内；国外
                if( !(typeof(area) == 'undefined' || area=="") ){
                    getCityLists(area)
                }
            });
        });

        function getCityLists(area) {
            $.ajax({
                url: getCityListUrl,
                data: {
                    nextPage: 0,
                    pageSize: 99999,
                    sortData: null,
                    jsonFilter:(typeof(area) == 'undefined' || area=="") ? null : "{'search_EQ_areaType':'"+ area +"'}"
                },
                type: 'POST',
                timeout: 7000,
                dataType: 'json'
            }).done(function (data) {
                if (data.code == 1) {
                    var _html = "<option value='' selected>请选择</option>";
                    for (var i = 0; i < data.object.content.length; i++) {
                        _html += "<option value='" + data.object.content[i].id + "'>" + data.object.content[i].areaName + "</option>";
                    }
                    $('#search_sysAreaId').html(_html);
                } else {
                    myAlert(data.message || tipMessage.undefined_msg);
                }
            }).fail(function (jqXHR, textStatus, errorThrown) {
                if (textStatus == "timeout") {
                    myAlert(tipMessage.timeout_msg || "请求超时");
                } else {
                    //myAlert(tipMessage.error_msg);
                }
            });
        }
    </script>
</head>
<body>
<section>
    <div>
        <div class="col-xs-12">
            <div class="box">
                <form id="search_form" class="form-horizontal">
                    <div class="tabSelect" id="selectHeadId">
                        <br>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">机构名称：</label>
                            <div class="col-md-8">
                                <input type="text" placeholder="机构名称" class="form-control input-sm"
                                       id="search_Institution_Name" name="institution_Name"/>
                            </div>
                        </div>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">宣传语：</label>
                            <div class="col-md-8">
                                <input type="text" placeholder="宣传语" class="form-control input-sm"
                                       id="search_Institution_Site" name="institution_Site"/>
                            </div>
                        </div>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">机构类型：</label>
                            <div class="col-md-8">
                                <select class="form-control input-sm" id="search_institution_type"
                                        name="institution_type">
                                    <option value="">请选择</option>
                                    <option value="0">享老居所</option>
                                    <option value="1">旅游居所</option>
                                    <option value="2">养护院</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">机构区域：</label>
                            <div class="col-md-8">
                                <select class="form-control input-sm" id="search_institution_Area"
                                        name="institution_Area">
                                    <option value="">请选择</option>
                                    <option value="0">国内</option>
                                    <option value="1">国外</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group  col-md-3 search-form">
                            <label class="col-md-4 control-label controls" for="">城市：</label>
                            <div class="col-md-8">
                                <select class="form-control input-sm" id="search_sysAreaId"
                                        name="sysAreaId">
                                    <option value="">请选择</option>
                                </select>
                            </div>
                        </div>

                        <input type="button" value="查询" id="search" class="btn btn-primary searchBtn">
                    </div>
                </form>
                <div class="box-body table-responsive" style="clear:both;">
                    <input type="button" value="新增" id="addSome" class="btn btn-success">
                    <input type="button" value="编辑" id="updateSome" class="btn btn-info">
                    <input type="button" value="删除" id="deleteSome" class="btn btn-danger">
                </div>
                <div class="box-body table-responsive">
                    <table id="example2" class="table table-bordered table-hover">
                        <thead>
                        <tr>
                            <th width="30"><input type="checkbox" id="_selectAll"/></th>
                            <th width="60">机构名称</th>
                            <th width="60">宣传语</th>
                            <th width="60">机构电话</th>
                            <th width="60">参观价格</th>
                            <th width="40">机构区域</th>
                            <th width="60">首页展示图</th>
                            <th width="60">机构类型</th>
                            <th width="30">排序值</th>
                            <th width="30">点击量</th>
                            <th width="60">操作</th>
                        </tr>
                        </thead>
                        <!-- 表格内容 start -->
                        <tbody id="mycontent"></tbody>
                        <!-- 表格内容 end -->
                    </table>
                    <!-- 分页标签 start -->
                    <div class="row page_big_div" id="displayPage"></div>

                    <!-- 分页标签 end -->
                    <script id="tableContentTmple" type="text/x-jsrender">
								<tr>
									<td><input id="ck_{{:id}}" ckId="{{:id}}" ckStatus="{{:status}}" class="ckSelect" type="checkbox" /></td>
									<td title={{:institution_Name}}  style="vertical-align:middle; text-align:left;">{{subStrings:institution_Name lens=15}}</td>
									<td title={{:institution_Site}}  style="vertical-align:middle; text-align:left;">{{subStrings:institution_Site lens=15}}</td>
									<td>{{:institution_TelPhone}}</td>
									<td title={{:institution_Price}} style="vertical-align:middle; text-align:right;">{{toThousands:institution_Price}}</td>
									<td>{{if institution_Area==0}}国内{{else institution_Area==1}}国外{{else}}无效{{/if}}({{:sysAreaVo.areaName}})</td>
									<td id="layer-photos-demo" class="layer-photos-demo">
										{{if institution_pic}}<img layer-src="../../{{:institution_pic}}" src="../../{{:institution_pic}}" height="40" width="50">{{else}}{{/if}}
									</td>
									<td>{{if institution_type==0}}享老居所{{else institution_type==1}}旅游居所{{else institution_type==2}}养护院{{else}}无效{{/if}}</td>
									<td>{{:sort}}</td>
									<td>{{:clickCont}}</td>
									<td><input type="button" value="机构房间" onclick="location.href='insHotelRoomsTableList.jsp?institutionId={{:id}}'" class="btn btn-info" style="width:auto;"></td>
							    </tr>

                    </script>
                </div>
            </div>
        </div>
</section>
</body>
</html>